package bio.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author Huhailong
 * @Description 伪异步I/O
 * @Date 2021/4/9.
 */
public class PseudoTimeServer {

    /**
     * main function
     * @param args params
     */
    public static void main(String[] args) {
        int port = 8080;
        try(ServerSocket serverSocket = new ServerSocket(port)){
            System.out.println("Pseudo Time Server is start in port: "+port);
            Socket socket = null;
            TimeServerHandlerThreadPool executor = new TimeServerHandlerThreadPool(10,100); //创建I/O线程池
            while(true){
                socket = serverSocket.accept();
                executor.execute(new TimeServerHandler(socket));
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
